package com.toubutu.audio.admin.controller;

import com.toubutu.anno.LoginRequired;
import com.toubutu.audio.admin.dto.AdminPageQueryComment;
import com.toubutu.audio.admin.vo.AdminCommentVo;
import com.toubutu.audio.common.PermissionCode;
import com.toubutu.audio.service.CommentService;
import com.toubutu.common.PageUtils;
import com.toubutu.common.Result;
import com.toubutu.permission.Permission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 朱鹏杰
 * @version 1.0
 * @date 2024年03月02日 0:06
 */
@RestController
@RequestMapping("/admin/comment")
@Api(tags = "后台评论接口")
@LoginRequired
public class AdminCommentController {
    @Resource
    private CommentService commentService;

    @PostMapping("/page")
    @ApiOperation("分页查询评论")
    @Permission(value = PermissionCode.Comment.COMMENT_LIST)
    public Result<PageUtils<AdminCommentVo>> pageQuery(@RequestBody AdminPageQueryComment dto){
        return Result.ok(commentService.adminPageQueryComment(dto));
    }

    @DeleteMapping("/delete/{commentId}")
    @Permission(value = PermissionCode.Comment.COMMENT_DELETE)
    public Result<Void> deleteComment(@PathVariable("commentId")Integer commentId){
        commentService.deleteCommentById(commentId);
        return Result.ok();
    }

}
